//
//  DDTabBarViewController.m
//  QMUIKitDemo
//
//  Created by Dxc_iOS on 2018/7/18.
//  Copyright © 2018年 Dxc_123. All rights reserved.
//

#import "DDBaseTabBarViewController.h"
#import "DDHomeViewController.h"
#import "DDSecondViewController.h"
#import "DDThirdViewController.h"
#import "DDBaseNavigationController.h"
@interface DDBaseTabBarViewController ()

@end

@implementation DDBaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpChildViewControllers];
}
/***  添加所有子控制器*/

-(void)setUpChildViewControllers{
    //首页
    
    DDHomeViewController *homeVC=[[DDHomeViewController alloc] init];
    [self setUpOneChildViewController:homeVC image:[UIImage imageNamed:@"tab_home_nor"]  selectedImage:[UIImage imageNamed:@"tab_home_pre"]  title:@"Frist"];
    DDSecondViewController *second= [[DDSecondViewController alloc] init];
    [self setUpOneChildViewController:second image:[UIImage imageNamed:@"tab_found_nor"]  selectedImage:[UIImage imageNamed:@"tab_fond_pre"]  title:@"Second"];
    DDThirdViewController *third=[[DDThirdViewController alloc] init];
    [self setUpOneChildViewController:third image:[UIImage imageNamed:@"tab_mine_nor"]  selectedImage:[UIImage imageNamed:@"tab_mine_pre"]  title:@"Third"];
    
    
}

/**添加一个子控制器的方法*/
- (void)setUpOneChildViewController:(UIViewController *)viewController image:(UIImage *)image selectedImage:(UIImage *)selectedImage  title:(NSString *)title{
    
    DDBaseNavigationController *BaseNav=[[DDBaseNavigationController alloc] initWithRootViewController:viewController];
    viewController.title = title;
    //    viewController.tabBarItem.title=title;
    
    
    //    tabBarItem 的选中和不选中文字属性
    [viewController .tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor grayColor]} forState:UIControlStateNormal];
    [viewController .tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:RGB(204, 62, 62)} forState:UIControlStateSelected];
    
    //    tabBarItem 的选中和不选中图片属性
    [viewController.tabBarItem setImage:[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [viewController.tabBarItem setSelectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    [self addChildViewController:BaseNav];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
